﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms.Design;
using System.ComponentModel.Design;
using System.Collections;
using System.Collections.ObjectModel;
using System.Windows.Forms;

namespace ProgNetComponentsDx.Controls.Design.Designers
{
    class MarkControlDesigner : ParentControlDesigner
    {
        public MarkControlDesigner()
            : base()
        {
            
        }

        public override ICollection AssociatedComponents
        {
            get
            {
                if (this.MControl == null)
                {
                    return base.AssociatedComponents;
                }
                else
                {
                    ArrayList arrayList = new ArrayList(base.AssociatedComponents);
                    if (!arrayList.Contains(MControl.ButtonMark))
                        arrayList.Add(MControl.ButtonMark);
                    if (!arrayList.Contains(MControl.ButtonUnMark))
                        arrayList.Add(MControl.ButtonUnMark);
                    return (ICollection)arrayList;
                }
            }
        }

        private MarkControl MControl
        {
            get { return Control as MarkControl; }
        }
        public override void Initialize(System.ComponentModel.IComponent component)
        {
            base.Initialize(component);
            EnableDesignMode(MControl.ButtonMark, "ButtonMark");
            EnableDesignMode(MControl.ButtonUnMark, "ButtonUnMark");
        }

    }

    public class MarkControlButtonDesigner : ControlDesigner
    {
        private MarkControlSimpleButton Button
        {
            get { return Control as MarkControlSimpleButton; }
        }
        private MarkControl MarkControl
        {
            get { return Button.MarkControl; }
        }
        public override SelectionRules SelectionRules
        {
            get
            {
                SelectionRules r = System.Windows.Forms.Design.SelectionRules.Visible;
                if (MarkControl != null && MarkControl.Orientation == Enums.DefaultOrientation.Default)
                    r |= System.Windows.Forms.Design.SelectionRules.Moveable;
                r |= System.Windows.Forms.Design.SelectionRules.AllSizeable;
                return r;
            }
        }
        public override bool CanBeParentedTo(IDesigner parentDesigner)
        {
            return parentDesigner.Component == MarkControl;
            //return base.CanBeParentedTo(parentDesigner);
        }
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);

            properties.Remove("Dock");
            properties.Remove("Name");
        }
    }
}
